{% extends "SchoolBuy/base.html" %}
{% block title %}物品信息{% endblock %}

{% block detial %}
    <script src="{{ STATIC_URL }}SchoolBuy/js/jquery-2.1.0.min.js"></script>
    <script src="{{ STATIC_URL }}SchoolBuy/js/jquery.swipebox.min.js"></script>
    <link rel="stylesheet" href="{{ STATIC_URL }}SchoolBuy/css/swipebox.min.css">

<div class="row">

    <div class="col-sm-12">

        <div class="king-block king-block-bordered">

            <div class="king-block-header king-gray-light">

                <h3 class="king-block-title">基本信息</h3>
            </div>
            <div class="king-block-content">

                <div class="form-horizontal">


                    <div class="form-group">
                        <label for="inputCount3" class="col-sm-3 control-label">标题：</label>
                        <label class="control-label">{{ goods.Title }}</label>
                    </div>
                    <div class="form-group">
                        <label for="inputCount3" class="col-sm-3 control-label">发布日期:</label>
                        <label class="control-label">{{ goods.Ctime }}</label>
                    </div>
                    <div class="form-group">
                        <label for="inputCout3" class="col-sm-3 control-label">描述:</label>
                        <label class="control-label">{{ goods.Details }}</label>
                    </div>
                    <div class="form-group">
                        <label for="inputCount3" class="col-sm-3 control-label">浏览量:</label>
                        <label class="control-label">{{ goods.PV }}</label>
                    </div>

                    <div class="form-group">
                        <label for="inputCount3" class="col-sm-3 control-label">发布者:</label>
                        <a href="{{ SITE_URL }}user/{{ goods.Owner.id }}">
                            <label class="control-label">{{ profile.Nick }} <img src="{{ profile.Avatar }}" height="50" width="50"></label>
                        </a>
                    </div>

                </div>
            </div>
        {% if image %}
            <div class="king-block-header king-gray-light">
                <h3 class="king-block-title">图片 (点击查看大图)</h3>
            </div>
            <div class="swipeboxEx" style="padding-left:25px;">
            <br>

                {% for i in image %}
                <a  href="{{  i.ImgBig }}" class="swipebox">
                    <img src="{{ i.ImgSma }}" alt="image">
                </a>
                {% endfor %}
            </div>
            <br>
        {% endif %}

        {% if words %}
            <div class="king-block-header king-gray-light">
                <h3 class="king-block-title">留言</h3>
            </div>
            <br>
            {% for i in words %}
            <div id="div-{{ i.id }}"  style="padding-left:25px;">
            {{ loop.index }}楼：
            <a href="{{ SITE_URL }}user/{{ i.From.User.id }}">{{ i.From.Nick }}</a>
            <img src="{{ i.From.Avatar }}" height="20" width="20">:
            {% if i.To %}
            回复：{{ i.To.From.Nick }}:"{{ i.To.Words }}"
            {% endif %}
            <a class="fa fa-at" title="回复" onclick="reply({{ i.id }});"></a>
            &nbsp;&nbsp;&nbsp;
            {% if i.From.User.id == uid %}
            <a href="{{ SITE_URL }}del/word/?good_id={{ goods.id }}&word_id={{ i.id }}" onClick="return confirm('确定删除?');">
                <i class="fa fa-close" title="删除"></i>
            </a>
            {% endif %}
            <br>
            <h4 class="alert-success">{{ i.Words }}</h4>
            </div>
            <hr color="#d8d8d8">
            {% endfor %}
            <br>

        {% endif %}
            <div class="king-block-header king-gray-light">
                <h3 class="king-block-title">回复留言</h3>
            </div>
            <div class="king-block-content">

                <form method="POST" action="{{ SITE_URL }}goods/reply/">
                    {% csrf_token %}
                    {{  csrf_input }}
                    {{ form }}
                    {{ zzz|default:'0'}}
                    <br>
                    <input type="hidden" name="goods_id" value="{{ goods.id }}">
                    <br>
                    <input type="submit" name="submit" class="king-btn king-success mr10" value="提交" />
                    <a href="javascript:rereset()" class="king-btn king-default"/>重置</a>
                </form>
            </div>
        </div>
    </div>
</div>




<script type="text/javascript">
    ;( function( $ ) {

        $( '.swipebox' ).swipebox();

    } )( jQuery );
</script>


<br>





<script type="text/javascript">
    function rereset(){
        var c = document.getElementById("id_To");
        c.value = "";
        d = document.getElementById("id_Words");
        d.placeholder="";
        d.value="";
    }

    function reply(id) {
        var c = document.getElementById("id_To");
        c.value = id;
        d = document.getElementById("id_Words");
        d.focus();
        var div = document.getElementById("div-"+id);
        var who = div.getElementsByTagName("a")[0].innerHTML;
        var mess = div.getElementsByTagName("h4")[0].innerHTML;
        d.placeholder="回复"+who+"的:"+mess;


    }
</script>

{% endblock %}